﻿namespace Tatuo.Modules.RefrigeratorDoor
{
    using System.Data.Linq;
    using System.Data.Linq.Mapping;
    using System.Data;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Linq;
    using System.Linq.Expressions;
    using System.ComponentModel;
    using System;

    /// <summary>
    /// Summary description for RefrigeratorDoorPartialMethods
    /// </summary>
    public partial class RefrigeratorTask : INotifyPropertyChanging, INotifyPropertyChanged
    {
        private string _StartDay;
        private string _StartHour;
        private string _StartMinutes;
        private string _StartMeridiem;
        private string _StopDay;
        private string _StopHour;
        private string _StopMinutes;
        private string _StopMeridiem;

        public DateTime ParsedStartDate
        {
            get
            {
                DateTime tmpDate = new DateTime();
                try
                {
                    tmpDate = DateTime.Parse(_StartDay + " " + _StartHour + ":" + _StartMinutes + ":00 " + _StartMeridiem);
                }
                catch (Exception)
                {
                }
                return tmpDate;
            }
        }

        public DateTime ParsedStopDate
        {
            get
            {
                DateTime compDate = new DateTime();
                DateTime tmpDate = new DateTime();
                try
                {
                    compDate = DateTime.Parse(_StartDay + " " + _StartHour + ":" + _StartMinutes + ":00 " + _StartMeridiem);
                    tmpDate = DateTime.Parse(_StopDay + " " + _StopHour + ":" + _StopMinutes + ":00 " + _StopMeridiem);

                    if (tmpDate < compDate)
                        tmpDate = compDate.AddMinutes(15);
                }
                catch (Exception)
                {
                }
                return tmpDate;
            }
        }

        public string StartDay
        {
            get { return Convert.ToDateTime(this.StartDate).ToString("d"); }
            set { _StartDay = value; }
        }
        public string StartHour
        {
            get { return Convert.ToDateTime(this.StartDate).ToString("hh"); }
            set { _StartHour = value; }
        }
        public string StartMinutes
        {
            get { return Convert.ToDateTime(this.StartDate).ToString("mm"); }
            set { _StartMinutes = value; }
        }
        public string StartMeridiem
        {
            get { return Convert.ToDateTime(this.StartDate).ToString("tt"); }
            set { _StartMeridiem = value; }
        }
        public string StopDay
        {
            get { return Convert.ToDateTime(this.StopDate).ToString("d"); }
            set { _StopDay = value; }
        }
        public string StopHour
        {
            get { return Convert.ToDateTime(this.StopDate).ToString("hh"); }
            set { _StopHour = value; }
        }
        public string StopMinutes
        {
            get { return Convert.ToDateTime(this.StopDate).ToString("mm"); }
            set { _StopMinutes = value; }
        }
        public string StopMeridiem
        {
            get { return Convert.ToDateTime(this.StopDate).ToString("tt"); }
            set { _StopMeridiem = value; }
        }
    }
}
